/**
 * Kohive.app.BoardPostsController
 * @extends ExtMVC.Controller
 * Manages the addition and removal of bookmarks
 */
Kohive.app.BoardPostsController = Ext.extend(
		Kohive.controllers.KohiveController, {
			name		: 'boardposts',
			title		: Ext.ux.Translator.translate('app_board_posts'),

			constructor	: function(config) {
				var config = config || {};

				// Get the OS and the controller
				var os = ExtMVC.OS.getOS();
				var controller = this;

				Kohive.app.BoardPostsController.superclass.constructor.call(
						this, {
							viewsPackage	: Kohive.views.boardposts
						}
				);

				this.actsAsKohiveController(Kohive.models.BoardPost);

				/**
				 * @action destroy 
				 * Deletes a given model instance
				 * We need to overwrite the default one for this controller as it doesn't seem to use the
				 * correct url (with _)
				 */
				this.registerAction('destroy', function(record, store,
								contentEl) {
							var id = record.get('id');
							if (id) {
								var u = new this.model({
											id	: id
										});
								u.destroy({
											scope	: this,
											url		: this.destroyUrl(id),
											success	: this.onDestroySuccess
													.createDelegate(this, [
																	store,
																	contentEl]),
											failure	: this.onDestroyFailure
										}
								);
							};
						}
				);
			},

			/**
			 * Renders the main window
			 */
			index		: function() {
				this.renderView('index', {

				});
			},

			/**
			 * Generates the destroy Url for a board post record using the saveUrl() method
			 */
			destroyUrl	: function(id) {
				return this.saveUrl() + '/' + id;
			}
		}
);

ExtMVC.OS.getOS().registerController('boardposts',
		Kohive.app.BoardPostsController
);